<template>
  <div class="history-data">
    <h3>历史记录</h3>
    <div v-for="(item, i) in list" :key="i" class="item" @click="onDetail(item)">{{ item.name }} 点击查看</div>
  </div>
</template>
<script setup>
import { computed } from 'vue';
import { useRouter } from 'vue-router';
import { useGraphData } from '@/store';
const graphDataStore = useGraphData();
const router = useRouter();
const list = computed(() => graphDataStore.data);

const onDetail = (item) => {
  router.push({ path: '/graph', query: { cells: JSON.stringify(item.cells) } });
  graphDataStore.setCurrentId(item.id);
};
</script>
<style lang="less" scoped>
.history-data {
  width: 180px;
  height: 100vh;
  padding: 10px;
  font-size: 12px;
  color: #fff;
  background: #545c64;

  h3 {
    font-size: 16px;
    line-height: 30px;
  }

  .item {
    line-height: 20px;
    cursor: pointer;
  }
}
</style>
